package dao

import (
	"shopAdd-srv/global"
	"shopAdd-srv/internal/model"
)

type OrderServiceImpl interface {
	OrderAdd(order model.Order) (int, error)
}
type OrderService struct {
}

func NewOrderService() *OrderService {
	return &OrderService{}
}
func (o *OrderService) OrderAdd(order model.Order) (int, error) {
	var orders model.Order

	orders = model.Order{
		ShopId:      order.ShopId,
		UserId:      order.UserId,
		Number:      1, // 默认 1件商品
		OrderStatus: 1, // 默认 未支付
	}
	err := orders.OrderAdd(global.DB)
	if err != nil {
		return 0, err
	}
	return int(orders.ID), nil

}
